package com.struts.web.manage.admin.station;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;

import com.lg.system.CLGAction;
import com.lg.system.MessageBean;
import com.struts.deal.admin.station.Deal;

public class AddKindOfStationAction extends CLGAction {

	public ActionForward execute(ActionMapping actionMapping, ActionForm form,
			HttpServletRequest request,
			HttpServletResponse response) throws
			Exception {

		AddKindOfStaForm aWebForm = (AddKindOfStaForm)form;
		ActionMessages msgs = new ActionMessages();
		MessageBean messageBean = new MessageBean();

		if(aWebForm.getMethod()!=null && aWebForm.getMethod().equals("add")){
			messageBean = Deal.addKindOfSta(request, aWebForm);
			if(messageBean.isResult()==true){
				return actionMapping.findForward("successmessages");
			}else{
				msgs.add("commonMsgs",new ActionMessage(messageBean.getMessage()));
				saveErrors(request,msgs);
				return actionMapping.findForward("fail");
			}
		}
		return actionMapping.getInputForward();
	}
}
